/*
*	Copyright (C) 2014  Julio Montes, Mario Carrillo
*
*	Julio Montes e-mail: imc.coder@gmail.com
*
*	Mario Carrillo e-mail: mario_90ago@live.com.mx
*
*	BSD 3-Clause License
*/

#ifndef SDK_MGR_H
#define SDK_MGR_H

#include <wx/wx.h>

#include "sdk/include/util.h"

namespace sdk
{
    template<class MgrT> class Mgr
    {
    public:
        static MgrT *Get()
        {
            if( !instance )
                instance = new MgrT;

            return instance;
        }

        static void Free()
        {
            delete instance;
            instance = 0;
        }
    protected:
        Mgr(){}
        virtual ~Mgr(){}

    private:
        static MgrT *instance;

        explicit Mgr(const Mgr<MgrT>&){};
        Mgr<MgrT>& operator=(Mgr<MgrT> const&){};
    };

    class MainFrame;

    class Manager
    {
    public:
        static void SetMainFrame( MainFrame *frame )
        {
            s_frame = frame;
        }
        static MainFrame *GetMainFrame()
        {
        #ifdef SDK_DEBUG
            if( s_frame == NULL )
            {
                LOGD( wxT( "Error: you need first set the mainframe (SetMainFrame)" ) );
            }
        #endif
            return s_frame;
        }
    protected:
    private:
        static MainFrame *s_frame;
    };
}

#endif // SDK_MGR_H
